import React, { Component } from 'react';
import HelloClass from './HelloClass';

// 高阶组件写法
interface Loading {
    loading: boolean;
}
function HelloHOC<P>( WrappedComponent: React.ComponentType<P>) {
    return class extends Component<P & Loading> {
        render() {
            const { loading, ...props } = this.props;
            return loading ? <div>Loading...</div> : <WrappedComponent {...props as P}></WrappedComponent>
        }
    }
}
export default HelloHOC(HelloClass);